<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <link rel="stylesheet" href="../css/topup.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="title">
        <em></em>
        <h3>充值记录</h3>
    </div>
    <form class="layui-form layui-form-padding" action="">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button type="button" class="layui-btn layui-btn-primary" lay-submit="" lay-filter="demo1">新增充值信息</button>
            </div>
        </div>
    </form>
    <div class="layuimini-main">
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
    <script type="text/html" id="staBar">
        {{#  if(d.status == '0'){ }}
        <span>未确认</span>
        {{#  }else if(d.status == '1'){ }}
        <span>已充值</span>
        {{#  }else if(d.status == '2'){ }}
        <span>驳回</span>
        {{#  } }}
    </script>
    <script type="text/html" id="currentTableBar">
        <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">下载税单</a>
    </script>
    <script type="text/html" id="imgTpl">
        <img src="{{ d.avatar }}">
    </script>
</div>
<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    var this_ = '';
    layui.use(['form', 'table','jquery','tfApi'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            $ = layui.jquery
            this_ = $,
            API = layui.tfApi;

        table.render({
            elem: '#currentTableId',
            url: API.CURL +  '/seller/qryInvoice',
            cellMinWidth: 60,
            method: "POST",
            contentType: 'application/json',
            xhrFields: {withCredentials: true},crossDomain: true,
            request:{
                pageName: "page",
                limitName : "pageSize"
            },
            parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list, //解析数据列表
                };
            },
            cols: [[
                {field: 'id', title: '流水号'},
                {field: 'sellerName', title: '商户名称'},
                {field: 'investAmount', title: '充值金额',templet: function (d) {
                        var _s = API.numFun(d.investAmount);
                        console.info(_s)
                        return '<b>'+_s+'</b>';
                    }},
                {field: 'serviceName',  title: '服务商'},
                {field: 'transer', title: '转账凭证',templet: function(d){
                        return '<div id="bigImg" onclick="show_img(this)" ><img src="'+d.transer+'" alt="" width="50px" height="50px" ></a></div>';
                    }
                },
                {field: 'comment', title: '备注'},
                {field: 'createTime', title: '时间'},
                {field: 'status', title: '状态', templet: "#staBar"}
            ]],
            page: true,
            //skin: 'line'
        });
        //监听提交
        form.on('submit(demo1)', function (data) {
            var index = layer.open({
                title: '新增转账凭证',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: '../page/table/edit.html',
                end:function(){
                    location.reload();
                }
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });
    });
    function show_img(t) {
        console.log("----->",t)
        var t = this_(t).find("img");
        //页面层
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
             area: ['80%', '80%'], //宽高
            shadeClose: true, //开启遮罩关闭
            end: function (index, layero) {
                return false;
            },
            content: '<div style="text-align:center"><img src="' + this_(t).attr('src') + '" /></div>'
        });
    }
</script>

</body>
</html>